var rootview = ui("$");
var do_App = sm("do_App");
var do_Page = sm("do_Page");
var nf = sm("do_Notification");
var openHelper = require("helper/open");
var userHelper = require("helper/user");
var activityUrl = require("url/activity");
var httpSilence = require("helper/httpSilence");
var dialog = sm("do_Dialog");
var helperOpen = require("helper/open");
// 创建一个External对象
var external = sm("do_External");

// ui
var aLayoutOpenDial = ui("aLayoutOpenDial");
var do_ALayout_remark=ui("do_ALayout_remark");
var do_Label_remark=ui("do_Label_remark");
var labelSignNick=ui("labelSignNick");

rootview.setMapping({ // 此处的Mapping只能设置在 RootView 上 ;
	"aLayoutOpenDial.tag" : "userPhone",
	"imageViewSignLogo.source" : "userLogo",
	"labelSignNick.text" : "userNick",
	"labelTime.text" : "dayMinutesNewAt",
	"labelPayType.text" : "showPayStatus",
	"do_Label_remark.text" : "remark",
	"do_Label_remark.tag" : "userId",
	"labelSignNick.tag" : "id"
});

rootview.on("dataRefreshed", function() {
	if(null!=aLayoutOpenDial.tag&&''!=aLayoutOpenDial.tag){
		aLayoutOpenDial.visible=true;
	}else{
		aLayoutOpenDial.visible=false;
	}
});
do_ALayout_remark.on("touch", function() {
	if(null!=userHelper.userId()&&do_Label_remark.tag==userHelper.userId()){
		updateRemark();
	}

})

ui("aLayoutSignLogo").on("touch", function() {
	var userId =ui("do_Label_remark").tag;
	if (userId) {
		openHelper.openPersonal(userId);
	}
})
function updateRemark() {
	var data1 = {
			title : "备注",
			hint : "输入备注内容"
		}
		dialog.open("source://view/reuse/popInput/pop_input.ui", data1, function(data1, e) {
			var params = {
					"id" : labelSignNick.tag,
					"remark" : data1,
				};
			httpSilence.post(activityUrl.url.sign.updateRemark, params, function(data) {
				do_Label_remark.text=data1;
			})
		});
}
aLayoutOpenDial.on("touch", function() {
	external.openDial(this.tag);

})

ui("aLayoutSignLogo").on("touch","",300,function(){
	helperOpen.openPersonal(do_Label_remark.tag);
})
